package mdm.com.sap.controller;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.tomcat.util.http.fileupload.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import mdm.com.sap.ModEnquiry;
import mdm.com.sap.Mod_FG;
import mdm.com.sap.SapUtil;
import mdm.com.sap.Sap_Operation;
import mdm.com.sap.Ftp.FtpUtil;
import mdm.com.sap.model.Enquiry_Zstock_Info;
import mdm.com.sap.model.GoodSmvt_item;
import mdm.com.sap.model.Hu_Info;
import mdm.com.sap.model.InputSelect;
import mdm.com.sap.model.Packing_station;
import mdm.com.sap.model.Per_Barcode;
import mdm.com.sap.model.Pre_Item;
import mdm.com.sap.model.Reason;
import mdm.com.sap.model.Return_Result;
import mdm.com.sap.model.St_Item;
import mdm.com.sap.model.Tnote_Hdr;
import mdm.com.sap.model.Tnote_Hu_TP;
import mdm.com.web.common.AjaxResponse;
import mdm.com.web.common.BaseController;
import mdm.com.web.common.Constant;
import mdm.com.web.service.IReasonService;

@Controller
@RequestMapping(value = "app")
@Api(description = "app功能模块")
public class PdaController extends BaseController {

    private static final Logger LOGGER = LoggerFactory.getLogger(PdaController.class);

    @Autowired
    private IReasonService iReasonService;

    /**
     * 转移单模块API 
     */
    @ApiOperation(value = "转移单/HU号查询", notes = "请求参数:<br>" + "tnote_number 转移单号或者HU号")
    @ResponseBody
    @RequestMapping(value = "/tnote", method = RequestMethod.POST)
    public AjaxResponse tnote(@RequestParam("tnote_number") String tnote_number) {
        LOGGER.info("-----tnote----tnote_number=" + tnote_number);
        Tnote_Hdr hdr = Sap_Operation.GetTnote(tnote_number);
        hdr.setLocation(Mod_FG.ZBAPI_FGWH_GET_TNOTE_DEF_LOC(hdr.getTnote_number()));
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, hdr);
    }

    @ApiOperation(value = "查询生产车间列表", notes = "请求参数:<br>")
    @ResponseBody
    @RequestMapping(value = "/packStation", method = RequestMethod.POST)
    public AjaxResponse packStation() {
        List<Packing_station> list = Sap_Operation.getPackStation();
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, list);
    }

    @ApiOperation(value = "继原有转移单添加HU", notes = "请求参数:<br>" + "hu_number HU号  <br>" + "返回参数注解： status:1  HU号已存在转移单 <br>"
            + "status:2  so号不一致 <br>  status:3  po号不一致 ")
    @ResponseBody
    @RequestMapping(value = "/tnoteAddHU", method = RequestMethod.POST)
    public AjaxResponse tnoteAddHU(@RequestParam("tnote_number") String tnote_number,
            @RequestParam("hu_number") String hu_number, @RequestParam("user_type") String user_type) {
        // 判断HU是否已存在转移单
        boolean inuse = Mod_FG.ZBAPI_FGWH_CHECK_HU_INUSE(hu_number);
        Return_Result inuseResult = Mod_FG.result;
        if (inuse) {
            String VBELN = "";// SO号
            String BSTKD = "";// 客人PO號
            Tnote_Hdr hdr = Sap_Operation.GetTnote(tnote_number);
            if (hdr.getList() != null) {
                if (hdr.getList().size() > 0) {
                    VBELN = hdr.getList().get(0).getVbeln();
                    BSTKD = hdr.getList().get(0).getBstkd();
                }
            }
            LOGGER.info("---------VBELN={" + VBELN + "},BSTKD={" + BSTKD + "}");
            List<Hu_Info> list = Mod_FG.ZBAPI_GET_DATA_BY_HU(hu_number, user_type);
            Return_Result Hu_InfoResult = Mod_FG.result;
            if (Hu_InfoResult.getT().equals("") || Hu_InfoResult.getT().equals("S")) {
                if (list != null) {
                    if (list.size() > 0) {
                        if (!VBELN.equals(list.get(0).getVbeln())) {
                            return AjaxResponse.reponseBody(2, "so number Don't match", null);
                        }
                        if (!BSTKD.equals(list.get(0).getBstkd())) {
                            return AjaxResponse.reponseBody(3, "po number Don't match", null);
                        }
                    }
                }
                Tnote_Hdr h = new Tnote_Hdr();
                h.setList(list);
                return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, h.getList());
            } else {
                return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, Hu_InfoResult);
            }
        } else {
            return AjaxResponse.reponseBody(1, inuseResult.getMESSAGE(), null);
        }
    }

    @ApiOperation(value = "保存原转移单新增HU号", notes = "请求参数:<br> tnote_number : 转移单号  <br>"
            + "add_hu_number : 前端所有的HU号   如果多个已‘,’ 逗号间隔<br>")
    @ResponseBody
    @RequestMapping(value = "/insertTnote", method = RequestMethod.POST)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tnote_number", value = "转移单号码", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "all_hu_number", value = "操作的HU号", dataType = "string", paramType = "query") })
    public AjaxResponse insertTnote(String tnote_number, String all_hu_number) {
        Tnote_Hdr hdr = Sap_Operation.GetTnote(tnote_number);

        System.out.println("=========hu number=====" + all_hu_number);
        // 前端所有的HU号list集合
        List<String> allhuNolist = new ArrayList<String>();
        if (all_hu_number != null) {
            String allhuNo[] = all_hu_number.split(",");
            for (String h : allhuNo) {
                allhuNolist.add(SapUtil.ForNum(h, 20));
            }
        }

        // SAP已有的HU号list集合
        List<String> existList = new ArrayList<String>();
        for (Hu_Info info : hdr.getList()) {
            existList.add(SapUtil.ForNum(info.getExidv(), 20));
        }

        LOGGER.info("====insertTnote==to add hu===" + SapUtil.toAddHuNo(existList, allhuNolist));
        LOGGER.info("====insertTnote==to delete hu===" + SapUtil.toDelHuNo(existList, allhuNolist));
        Return_Result addres = Sap_Operation.AddTnote(hdr, SapUtil.toAddHuNo(existList, allhuNolist));
        Return_Result delres = Sap_Operation.DeleteTnote(hdr, SapUtil.toDelHuNo(existList, allhuNolist));
        JSONObject result = new JSONObject();
        result.put("addres", addres);
        result.put("delres", delres);
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, result);
    }

    @ApiOperation(value = "删除转移单中的HU", notes = "请求参数:<br> tnote_number : 转移单号  <br>"
            + "hu_number : 添加的HU号   如果多个已‘,’ 逗号间隔")
    @ResponseBody
    @RequestMapping(value = "/deleteTnote", method = RequestMethod.POST)
    public AjaxResponse deleteTnote(@RequestParam("tnote_number") String tnote_number,
            @RequestParam("hu_number") String hu_number) {
        Tnote_Hdr hdr = Sap_Operation.GetTnote(tnote_number);
        String huNo[] = hu_number.split(",");
        List<String> huNolist = new ArrayList<String>();
        for (String h : huNo) {
            huNolist.add(h);
        }
        Return_Result res = Sap_Operation.DeleteTnote(hdr, huNolist);
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, res);
    }

    @ApiOperation(value = "新建转移单添加HU", notes = "请求参数:<br>" + "hu_number HU号  <br>" + "返回参数注解： status:1  HU号已存在转移单 <br>"
            + "status:2  so号不一致 <br>  status:3  po号不一致 ")
    @ResponseBody
    @RequestMapping(value = "/createtnoteAddHU", method = RequestMethod.POST)
    public AjaxResponse createtnoteAddHU(@RequestParam("hu_number") String hu_number,
            @RequestParam("user_type") String user_type) {
        // 判断HU是否已存在转移单
        boolean inuse = Mod_FG.ZBAPI_FGWH_CHECK_HU_INUSE(hu_number);
        Return_Result inuseResult = Mod_FG.result;
        if (inuse) {
            List<Hu_Info> list = Mod_FG.ZBAPI_GET_DATA_BY_HU(hu_number, user_type);
            return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, list);
        } else {
            return AjaxResponse.reponseBody(1, inuseResult.getMESSAGE(), null);
        }
    }

    @ApiOperation(value = "新建转移单", notes = "请求参数:<br> pscode : 生产车间号  <br>" + "hu_number : 添加的HU号   如果多个已‘,’ 逗号间隔")
    @ResponseBody
    @RequestMapping(value = "/createTnote", method = RequestMethod.POST)
    public AjaxResponse createTnote(@RequestParam("pscode") String pscode, @RequestParam("hu_number") String hu_number,
            @RequestParam("user_type") String user_type) {
        String huNo[] = hu_number.split(",");
        List<String> hulist = new ArrayList<String>();
        // List<Tnote_Hu> hulist = new ArrayList<Tnote_Hu>();
        for (String str : huNo) {
            // Tnote_Hu hu = new Tnote_Hu();
            // hu.setExidv(str);
            hulist.add(str);
        }
        List<Hu_Info> list = null;
        for (String hu : hulist) {
            list = Mod_FG.ZBAPI_GET_DATA_BY_HU(hu, user_type);
            break;
        }
        // 绑定转移单初始话信息
        Tnote_Hdr hdr = new Tnote_Hdr();
        hdr.setPscode(pscode);
        hdr.setTnote_status("CREATED");
        if (list != null) {
            for (Hu_Info info : list) {
                hdr.setOrdernumber(info.getAufnr());
                hdr.setTnote_number(info.getTnote_number());
            }
        }
        Return_Result res = Sap_Operation.CreateTnote(hdr, hulist);
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, res);
    }

    /**
     * 查询功能模块API
     * 
     */
    @ApiOperation(value = "客人PO查询转移单号", notes = "请求参数:<br> poNo : 客人PO ")
    @ResponseBody
    @RequestMapping(value = "/getTnoteByPo", method = RequestMethod.POST)
    public AjaxResponse getTnoteByPo(@RequestParam("poNo") String poNo) {
        LOGGER.info("-----getTnoteByPo-----" + poNo);
        List<String> list = Sap_Operation.Cpo_Get_Tnote(poNo.toUpperCase(), "", "");
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, list);
    }

    @ApiOperation(value = "销售单号查询转移单号", notes = "请求参数:<br> VBELN : 销售单号 < br> POSNO:项目号")
    @ResponseBody
    @RequestMapping(value = "/getTnoteByVbeln", method = RequestMethod.POST)
    @ApiImplicitParams({ @ApiImplicitParam(name = "vbeln", value = "销售单号", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "psono", value = "项目号", dataType = "string", paramType = "query") })
    public AjaxResponse getTnoteByVbeln(String vbeln, String psono) {
        LOGGER.info("-----getTnoteByVbeln----VBELN={},POSNO={}[" + vbeln + "],[" + psono + "]");
        List<String> list = Sap_Operation.Cpo_Get_Tnote("", vbeln, psono);
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, list);
    }

    @ApiOperation(value = "查询HU信息", notes = "请求参数:<br> hu_number : HU号码 ")
    @ResponseBody
    @RequestMapping(value = "/getDataByHu", method = RequestMethod.POST)
    public AjaxResponse getDataByHu(@RequestParam("hu_number") String hu_number,
            @RequestParam("user_type") String user_type) {
        LOGGER.info("-----getDataByHu----hu_number=[" + hu_number + "]====user_type=" + user_type);
        List<Hu_Info> list = Mod_FG.ZBAPI_GET_DATA_BY_HU(hu_number, user_type);
        Tnote_Hdr hdr = new Tnote_Hdr();
        hdr.setList(list);
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, hdr.getList());
    }

    @ApiOperation(value = "查询HU信息2", notes = "请求参数:<br> hu_number : HU号码 ")
    @ResponseBody
    @RequestMapping(value = "/getDataByHu2", method = RequestMethod.POST)
    public AjaxResponse getDataByHu2(@RequestParam("hu_number") String hu_number,
            @RequestParam("user_type") String user_type) {
        LOGGER.info("-----getDataByHu2----hu_number=[" + hu_number + "]---user_type=" + user_type);
        List<Hu_Info> list = Mod_FG.ZBAPI_GET_DATA_BY_HU2(hu_number, user_type);
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, list);
    }

    /**
     * 收货API
     */

    @ApiOperation(value = "收货保存", notes = "请求参数:<br> tnote_number : 转移单号 < br> pLocation: 仓位")
    @ResponseBody
    @RequestMapping(value = "/saveTransfer", method = RequestMethod.POST)
    public AjaxResponse saveTransfer(@RequestParam("tnote_number") String tnote_number,
            @RequestParam("pLocation") String pLocation) {

        LOGGER.info("-----getTnoteByVbeln----tnote_number={},pLocation={}[" + tnote_number + "],[" + pLocation + "]");

        if (pLocation == null || pLocation.equals("")) {
            pLocation = Mod_FG.ZBAPI_FGWH_GET_TNOTE_DEF_LOC(tnote_number);
        }

        List<Tnote_Hu_TP> list = Mod_FG.ZBAPI_FGWH_GET_TNOTE_FOR_TP2(tnote_number, pLocation);

        System.out.println("==================size=============" + list.size());

        if (list.size() == 0) {
            Return_Result r = Mod_FG.result;
            return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, r);
        }

        Return_Result res = Sap_Operation.saveTransfer(tnote_number, pLocation, list);

        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, res);
    }

    /**
     * 交货单 API
     */

    @ApiOperation(value = "查询交货单HU", notes = "请求参数:<br> pDNote : 交货单号 < br> pPackID: 清单号码")
    @ResponseBody
    @RequestMapping(value = "/getPckList", method = RequestMethod.POST)
    public AjaxResponse getPckList(@RequestParam("pDNote") String pDNote, @RequestParam("pPackID") String pPackID,
            @RequestParam("user_type") String user_type) {

        LOGGER.info("-----getTnoteByVbeln----pDNote={},pPackID={}[" + pDNote + "],[" + pPackID + "]");

        List<String> huNoList = Sap_Operation.GetDn_Pck_List(pDNote, pPackID, user_type);

        List<Hu_Info> infolist = Mod_FG.ZBAPI_GET_DATA_BY_HU(huNoList, user_type);

        Tnote_Hdr hdr = new Tnote_Hdr();
        hdr.setList(infolist);
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, hdr.getList());
    }

    @ApiOperation(value = "交货单保存", notes = "请求参数:<br> pDNote : 交货单号 < br> hu_number: HU号 逗号间隔")
    @ResponseBody
    @RequestMapping(value = "/savePckLink", method = RequestMethod.POST)
    // @ApiImplicitParams({ @ApiImplicitParam(name = "pDNote", value = "交货单号",
    // dataType = "string"),
    // @ApiImplicitParam(name = "hu_number", value = "HU号 逗号间隔", dataType =
    // "string") })
    public AjaxResponse savePckLink(@RequestParam("pDNote") String pDNote,
            @RequestParam("hu_number") String hu_number) {

        LOGGER.info("-----getTnoteByVbeln----pDNote={},hu_number={}[" + pDNote + "],[" + hu_number + "]");

        String huNo[] = hu_number.split(",");

        List<String> list = new ArrayList<String>();
        for (String str : huNo) {
            System.out.println(str);
            list.add(str);
        }

        Return_Result res = Sap_Operation.Save_Pck_Link(pDNote, list);

        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, res);
    }

    @ApiOperation(value = "扫描条码收货", notes = "")
    @ResponseBody
    @RequestMapping(value = "/save_Hu_Goods_Mov", method = RequestMethod.POST)
    // @ApiImplicitParams({ @ApiImplicitParam(name = "pHuNo", value = "HU号码，多个HU
    // 逗号间隔", dataType = "string"),
    // @ApiImplicitParam(name = "pLocation", value = "仓位", dataType = "string"),
    // @ApiImplicitParam(name = "user_type", value = "登录用户访问类型", dataType =
    // "string") })
    public AjaxResponse save_Hu_Goods_Mov(@RequestParam("pHuNo") String pHuNo,
            @RequestParam("pLocation") String pLocation, @RequestParam("user_type") String user_type) {
        LOGGER.info("pHuNo=" + pHuNo + "   pLocation=" + pLocation + "    user_type=" + user_type);
        String huNo[] = pHuNo.split(",");
        List<String> list = new ArrayList<String>();
        for (String str : huNo) {
            list.add(str);
        }
        List<Hu_Info> listhuinfo = Mod_FG.ZBAPI_GET_DATA_BY_HU(list, user_type);
        Tnote_Hdr hdr = new Tnote_Hdr();
        hdr.setList(listhuinfo);
        Return_Result res = Sap_Operation.Save_fgwh_Goods_Mov(list, hdr.getList(), pLocation, user_type);
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, res);
    }

    @ApiOperation(value = "取消收货", notes = "")
    @ResponseBody
    @RequestMapping(value = "/cancel_GR_By_Hu", method = RequestMethod.POST)
    public AjaxResponse cancel_GR_By_Hu(@RequestParam("pHuNo") String pHuNo,
            @RequestParam("user_type") String user_type) {
        LOGGER.info("--------------------pHuNo:" + pHuNo);
        String huNo[] = pHuNo.split(",");
        List<String> list = new ArrayList<String>();
        for (String str : huNo) {
            list.add(str);
        }
        Return_Result res = Sap_Operation.ZBAPI_CANCEL_GR_BY_HU(list, user_type);
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, res);
    }

    @ApiOperation(value = "转仓", notes = "")
    @ResponseBody
    @RequestMapping(value = "/roll_over", method = RequestMethod.POST)
    public AjaxResponse roll_over(@RequestParam("pHuNo") String pHuNo, @RequestParam("pLoc") String pLoc,
            @RequestParam("user_type") String user_type) {
        LOGGER.info("pHuNo=[" + pHuNo + "]   pLoc=[" + pLoc + "]    user_type=[" + user_type + "]");
        String huNo[] = pHuNo.split(",");
        List<String> list = new ArrayList<String>();
        for (String str : huNo) {
            list.add(str);
        }
        Return_Result res = Sap_Operation.ZBAPI_LOC_TX_BY_HU_NEW(list, pLoc, user_type);
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, res);
    }

    @ApiOperation(value = "更新重量", notes = "请求参数:<br>" + "pHUKey HU号  <br>" + "pHUKey ： 新毛重     <br> pWeight:  新净重")
    @ResponseBody
    @RequestMapping(value = "/updateWeight", method = RequestMethod.POST)
    public AjaxResponse updateWeight(@RequestParam("pHUKey") String pHUKey, @RequestParam("pWeight") String pWeight,
            @RequestParam("pNetWeight") String pNetWeight) {
        Return_Result res = Sap_Operation.BAPI_HU_CHANGE_HEADER_OLD(pHUKey, pWeight, pNetWeight);
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, res);
    }

    @ApiOperation(value = "装箱单号查询", notes = "请求参数:<br>" + "pPackingID  装箱号 <br>" + "user_type ：      ")
    @ResponseBody
    @RequestMapping(value = "/getPacking", method = RequestMethod.POST)
    public AjaxResponse getPacking(@RequestParam("pPackingID") String pPackingID,
            @RequestParam("user_type") String user_type) {

        List<Hu_Info> list = Sap_Operation.ZBAPI_GET_HU_BY_PACKING(pPackingID, user_type);
        Tnote_Hdr hdr = new Tnote_Hdr();
        hdr.setList(list);
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, hdr.getList());
    }

    @ApiOperation(value = "装箱单明细匹配", notes = "请求参数:<br>" + "exidv  HU号码")
    @ResponseBody
    @RequestMapping(value = "/PackingAddHu", method = RequestMethod.POST)
    public AjaxResponse PackingAddHu(@RequestParam("packingID") String packingID, @RequestParam("exidv") String exidv,
            @RequestParam("user_type") String user_type) {

        // List<Hu_Info> list = Mod_FG.ZBAPI_GET_DATA_BY_HU(exidv,user_type);
        // List<String> exidv2 = new ArrayList<String>();
        //
        // for (Hu_Info info : list) {
        // exidv2.add(info.getExidv2());
        // }
        Return_Result res = Sap_Operation.ZBAPI_MTH_PCK_LST_CTN_BY_DATA(packingID, exidv, user_type);

        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, res);
    }

    @ApiOperation(value = "找实物 获取服务器目录及文件", notes = "")
    @ResponseBody
    @RequestMapping(value = "/getFtpfileName", method = RequestMethod.POST)
    public AjaxResponse getFtpfileName() throws IOException {
        FtpUtil ftputil = new FtpUtil(true);
        List<String> list = null;
        if (ftputil.login(this.localConfig.getFTP_IP(), 21, this.localConfig.getFTP_USR(),
                this.localConfig.getFTP_PWD())) {
            list = ftputil.List("/Barcode_To_Real/"); // 获取该目录下的文件夹名称
        }
        ftputil.disConnection();
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, list);
    }

    @ApiOperation(value = "找实物 获取服务器目录文件夹下的TXT文件", notes = "fileName 文件夹名称")
    @ResponseBody
    @RequestMapping(value = "/getFtpfileNameToTxt", method = RequestMethod.POST)
    public AjaxResponse getFtpfileNameToTxt(@RequestParam("fileName") String fileName) throws IOException {
        FtpUtil ftputil = new FtpUtil(true);
        List<String> list = null;
        if (ftputil.login(this.localConfig.getFTP_IP(), 21, this.localConfig.getFTP_USR(),
                this.localConfig.getFTP_PWD())) {
            list = ftputil.List("/Barcode_To_Real/" + fileName + "/", "txt"); // 获取该目录下的文件夹名称
        }
        ftputil.disConnection();
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, list);
    }

    @ApiOperation(value = "显示条码信息", notes = "pathName : 文件夹名称 <br>fileName 文件名称")
    @ResponseBody
    @RequestMapping(value = "/showTxtValue", method = RequestMethod.POST)
    public AjaxResponse showTxtValue(@RequestParam("pathName") String pathName,
            @RequestParam("fileName") String fileName) throws IOException {
        FtpUtil ftputil = new FtpUtil(true);
        List<String> list = null;
        if (ftputil.login(this.localConfig.getFTP_IP(), 21, this.localConfig.getFTP_USR(),
                this.localConfig.getFTP_PWD())) {
            String mypath = "/Barcode_To_Real/" + pathName + "/";
            list = ftputil.readFile(mypath, fileName);
        }
        ftputil.disConnection();
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, list);
    }

    @ApiOperation(value = "删除文件", notes = "pathName : 文件夹名称 <br>fileName 文件名称")
    @ResponseBody
    @RequestMapping(value = "/deleteTxtFile", method = RequestMethod.POST)
    public AjaxResponse deleteTxtFile(@RequestParam("pathName") String pathName,
            @RequestParam("fileName") String fileName) throws IOException {
        // FtpUtil ftputil = new FtpUtil(true);
        // boolean type = false;
        // if (ftputil.login(this.localConfig.getFTP_IP(), 21,
        // this.localConfig.getFTP_USR(),
        // this.localConfig.getFTP_PWD())) {
        // String mypath = "/Barcode_To_Real/" + pathName.trim() + "/";
        // type = ftputil.deleteFile(mypath, fileName);
        // }
        // ftputil.disConnection();
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, true);
    }

    @ApiOperation(value = "扫描条码", notes = "HuNo HU号逗号间隔")
    @ResponseBody
    @RequestMapping(value = "/saveFtpTxt", method = RequestMethod.POST)
    public AjaxResponse saveFtpTxt(@RequestParam("huno") String huno, @RequestParam("pscode") String pscode)
            throws IOException {
        FtpUtil ftputil = new FtpUtil(true);
        if (ftputil.login(this.localConfig.getFTP_IP(), 21, this.localConfig.getFTP_USR(),
                this.localConfig.getFTP_PWD())) {
            List<String> list = new ArrayList<String>();
            String hu[] = huno.split(",");
            for (String str : hu) {
                list.add(str);
            }
            ftputil.uploadFile("/" + pscode + "/", list);
        }
        ftputil.disConnection();
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, true);
    }

    @ApiOperation(value = "棉、辅料、布的库存列表查询", notes = "请求参数:<br>" + "barcode 条码" + "tankNo  缸号" + "color 颜色组"
            + "materialNo 物料号" + "grid_value 网格值" + "locationID 仓位" + "PONo PO号")
    @ResponseBody
    @RequestMapping(value = "/stockSelect", method = RequestMethod.POST)
    public AjaxResponse stockSelect(InputSelect inputSelect) {
        String str = "";

        LOGGER.info("-----stockSelect----barcode=" + inputSelect.getBarcode() + "-----stockSelect----tankNo="
                + inputSelect.getTankNo() + "-----stockSelect----color=" + inputSelect.getColor()
                + "-----stockSelect----materialNo=" + inputSelect.getMaterialNo() + "-----stockSelect----grid_value="
                + inputSelect.getGrid_value() + "-----stockSelect----locationID=" + inputSelect.getLocationID()
                + "-----stockSelect----PONo=" + inputSelect.getPONo() + "-----stockSelect----zbukrs="
                + inputSelect.getZbukrs() + "===str=" + str);

        List<Enquiry_Zstock_Info> list = ModEnquiry.ZBAPI_GET_STOCK_INFO_BY_BC(inputSelect.getBarcode(),
                inputSelect.getTankNo(), inputSelect.getColor(), inputSelect.getMaterialNo(),
                inputSelect.getGrid_value(), inputSelect.getLocationID(), inputSelect.getPONo(),
                inputSelect.getZbukrs());
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, list);
    }

    @ApiOperation(value = "根据备料单号查询到备料列表", notes = "请求参数:<br>" + "prepareNo 备料单号")
    @ResponseBody
    @RequestMapping(value = "/materialNumSelect", method = RequestMethod.POST)
    public AjaxResponse materialNumSelect(@RequestParam("prepareNo") String prepareNo) {
        LOGGER.info("-----stockSelect----prepareNo=" + prepareNo);
        List<Pre_Item> list = ModEnquiry.ZBAPI_PREORD_GET_PRE_ITEM(prepareNo);
        Return_Result result = ModEnquiry.result;
        JSONObject jsonRes = new JSONObject();
        jsonRes.put("list", list);
        jsonRes.put("res", result);
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, jsonRes);
    }

    @ApiOperation(value = "根据备料单号查询到备料列表", notes = "请求参数:<br>" + "prepareNo 备料单号")
    @ResponseBody
    @RequestMapping(value = "/fmaterialNumSelect", method = RequestMethod.POST)
    public AjaxResponse fmaterialNumSelect(@RequestParam("prepareNo") String prepareNo) {
        LOGGER.info("-----stockSelect----prepareNo=" + prepareNo);
        List<Pre_Item> list = ModEnquiry.FZBAPI_PREORD_GET_PRE_ITEM(prepareNo);
        Return_Result result = ModEnquiry.result;
        JSONObject jsonRes = new JSONObject();
        jsonRes.put("list", list);
        jsonRes.put("res", result);
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, jsonRes);
    }

    @ApiOperation(value = "发料", notes = "请求参数:<br>" + "prepareNo 备料单号" + "id 领料id" + "str 备料详情")
    @ResponseBody
    @RequestMapping(value = "/picking", method = RequestMethod.POST)
    public AjaxResponse picking(@RequestParam("prepareNo") String prepareNo, @RequestParam("id") String id,
            @RequestParam("strs") String strs) {
        LOGGER.info("--------prepareNo=" + prepareNo + "--------id=" + id + "--------strs=" + strs);
        Return_Result result = ModEnquiry.ZBAPI_PREORD_GI(prepareNo, id, strs);
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, result);
    }

    @ApiOperation(value = "备料完成", notes = "请求参数:<br>" + "str 备料详情" + "code 状态")
    @ResponseBody
    @RequestMapping(value = "/materials", method = RequestMethod.POST)
    public AjaxResponse materials(@RequestParam("str") String str) {
        LOGGER.info("-----materials----str=" + str);
        Return_Result result = ModEnquiry.ZBAPI_PREORD_STS_CHG(str);
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, result);
    }

    @ApiOperation(value = "转架位", notes = "请求参数:<br>" + "str 条码信息，多条已逗号间隔" + "TargetLocation 转架号")
    @ResponseBody
    @RequestMapping(value = "/Tardistrict", method = RequestMethod.POST)
    public AjaxResponse Tardistrict(@RequestParam("str") String str,
            @RequestParam("TargetLocation") String TargetLocation) {
        LOGGER.info("---------str=" + str + "---------TargetLocation=" + TargetLocation);
        Return_Result res = ModEnquiry.AFS_BAPI_GOODSMVT_CREATE(str, TargetLocation);
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, res);
    }

    @ApiOperation(value = "条码转架位", notes = "请求参数:<br>" + "str 条码信息，多条已逗号间隔" + "TargetLocation 转架号")
    @ResponseBody
    @RequestMapping(value = "/district", method = RequestMethod.POST)
    public AjaxResponse district(@RequestParam("str") String str,
            @RequestParam("TargetLocation") String TargetLocation) {
        LOGGER.info("---------str=" + str + "---------TargetLocation=" + TargetLocation);

        List<String> barcode_list = SapUtil.stringToLists(str);

        List<Enquiry_Zstock_Info> info_list = ModEnquiry.ZBAPI_GET_STOCK_INFO_BY_BC("X", str, "", "", "", "", "", "",
                "");
        Return_Result info_result = ModEnquiry.result;
        List<GoodSmvt_item> item_list = new ArrayList<GoodSmvt_item>();
        for (Enquiry_Zstock_Info info : info_list) {
            barcode_list.remove(info.getZbar_code());

            GoodSmvt_item item = new GoodSmvt_item();
            item.setBATCH(info.getCharg());
            item.setMATERIAL(info.getMatnr());
            item.setPLANT(info.getWerks());
            item.setSTGE_LOC(info.getLgort());
            item.setGRID_VALUE(info.getJ_3asize());
            item.setENTRY_QNT(info.getMenge());
            if (!info.getVbeln().equals("")) {
                item.setSPEC_STOCK("E");
                item.setVAL_S_ORD_ITEM(info.getPosnr());
                item.setVAL_SALES_ORD(info.getVbeln());
            } else {
                item.setSPEC_STOCK(" ");
                item.setVAL_S_ORD_ITEM("");
                item.setVAL_SALES_ORD("");
            }
            switch (info.getZsto_type()) {
                case "非限制库存":
                    item.setMOVE_TYPE("311");
                    break;
                case "QI库存":
                    item.setMOVE_TYPE("323");
                    break;
                case "冻结库存":
                    item.setMOVE_TYPE("325");
                    break;
                default:
                    item.setMOVE_TYPE("311");
                    break;
            }
            item.setMOVE_STLOC(TargetLocation.toUpperCase());
            item_list.add(item);
        }
        JSONObject result = new JSONObject();
        result.put("NoStock", barcode_list);
        if (item_list.size() > 0) {
            List<Return_Result> list = ModEnquiry.AfsGoodsMvtCreate(item_list);
            result.put("defeated", list);
        } else {
            List<Return_Result> list = new ArrayList<Return_Result>();
            list.add(info_result);
            result.put("defeated", list);
        }
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, result);
    }

    @ApiOperation(value = "发料完成", notes = "请求参数:<br>" + "pPrepOrderNo 备料单号" + "pNewStatus 状态")
    @ResponseBody
    @RequestMapping(value = "/expected", method = RequestMethod.POST)
    public AjaxResponse expected(@RequestParam("pPrepOrderNo") String pPrepOrderNo,
            @RequestParam("pNewStatus") String pNewStatus) {
        LOGGER.info("-----expected----pPrepOrderNo=" + pPrepOrderNo + "-----expected----pNewStatus=" + pNewStatus);
        Return_Result result = ModEnquiry.ZBAPI_PREORD_STS_CHG_M(pPrepOrderNo, pNewStatus);
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, result);
    }

    @ApiOperation(value = "转待领料区", notes = "请求参数:<br>" + "str 备料详情" + "pMachineNo 备料单号")
    @ResponseBody
    @RequestMapping(value = "/receiving", method = RequestMethod.POST)
    public AjaxResponse receiving(@RequestParam("strs") String strs, @RequestParam("pMachineNo") String pMachineNo) {
        LOGGER.info("-----receiving----strs=" + strs + "-----receiving----pMachineNo=" + pMachineNo);
        Return_Result result = ModEnquiry.ZBAPI_PREORD_GDS_MVT(strs, pMachineNo);
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, result);
    }

    @ApiOperation(value = "棉、辅料、布的库存列表查询", notes = "请求参数:<br>" + "barcode 条码" + "tankNo  缸号" + "color 颜色组"
            + "materialNo 物料号" + "grid_value 网格值" + "locationID 仓位" + "PONo PO号")
    @ResponseBody
    @RequestMapping(value = "/getStockInfoForPrepareItem", method = RequestMethod.POST)
    public AjaxResponse getStockInfoForPrepareItem(InputSelect inputSelect,
            @RequestParam("user_type") String user_type) {
        LOGGER.info("--------barcode=" + inputSelect.getBarcode() + "---------tankNo=" + inputSelect.getTankNo()
                + "-----color=" + inputSelect.getColor() + "--------materialNo=" + inputSelect.getMaterialNo()
                + "---------grid_value=" + inputSelect.getGrid_value() + "------locationID="
                + inputSelect.getLocationID() + "-------PONo=" + inputSelect.getPONo() + "-----zbukrs="
                + inputSelect.getZbukrs() + "==" + "user_type=" + user_type);

        List<Enquiry_Zstock_Info> list = ModEnquiry.ZBAPI_GET_STOCK_INFO_BY_BC("X", inputSelect.getBarcode(),
                inputSelect.getTankNo(), inputSelect.getColor(), inputSelect.getMaterialNo(),
                inputSelect.getGrid_value(), inputSelect.getLocationID(), inputSelect.getPONo(),
                inputSelect.getZbukrs());

        Return_Result result = ModEnquiry.result;

        List<Enquiry_Zstock_Info> _list = new ArrayList<Enquiry_Zstock_Info>();
        List<Enquiry_Zstock_Info> _tmp = new ArrayList<Enquiry_Zstock_Info>();
        Enquiry_Zstock_Info res = new Enquiry_Zstock_Info();
        for (int i = 0; i < list.size(); i++) {
            if (!ModEnquiry.getFilterLocation(user_type).contains(list.get(i).getLgort())) {
                _list.add(list.get(i));
            }
        }

        for (int j = 0; j < _list.size(); j++) {
            if (j == 0) {
                res = _list.get(j);
            } else {
                double menge = Double.parseDouble(res.getMenge()) + Double.parseDouble(_list.get(j).getMenge());
                DecimalFormat df = new DecimalFormat("#.000");
                String str = df.format(menge);
                res.setMenge(str);
            }
        }
        _tmp.add(res);
        JSONObject jsonRes = new JSONObject();
        jsonRes.put("list", _tmp);
        jsonRes.put("res", result);
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, jsonRes);
    }

    @ApiOperation(value = "条码详情", notes = "请求参数:<br>" + "")
    @ResponseBody
    @RequestMapping(value = "/getBarcode", method = RequestMethod.POST)
    public AjaxResponse getBarcode(@RequestParam("pmtnr") String pmtnr, @RequestParam("pritm") String pritm) {
        LOGGER.info("--------pmtnr=" + pmtnr + "----pritm=" + pritm);
        List<Per_Barcode> list = ModEnquiry.ZBAPI_GET_SERIAL_GI(pmtnr, pritm);
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, list);
    }

    @ApiOperation(value = "备料原因", notes = "请求参数:<br>" + "")
    @ResponseBody
    @RequestMapping(value = "/getReason", method = RequestMethod.POST)
    public AjaxResponse getReason() {
        List<Reason> list = iReasonService.getReason();
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, list);
    }

    @ApiOperation(value = "备料完成", notes = "请求参数:<br>" + "str 备料详情" + "code 状态")
    @ResponseBody
    @RequestMapping(value = "/modMaterials", method = RequestMethod.POST)
    public AjaxResponse modMaterials(@RequestParam("pMachineNo") String pMachineNo,
            @RequestParam("reasondesc") String reasondesc, @RequestParam("status") String status) {

        LOGGER.info("-----materials----pMachineNo=[" + pMachineNo + "]  reasondesc=[" + reasondesc + "]  status=["
                + status + "]");

        Return_Result result = ModEnquiry.ZBAPI_PREORD_STS_CHG(pMachineNo, reasondesc, status);

        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, result);
    }

    @ApiOperation(value = "版本检测", notes = "请求参数:<br>" + "")
    @ResponseBody
    @RequestMapping(value = "/checkVersion", method = RequestMethod.POST)
    public AjaxResponse checkVersion() {
        String path = localConfig.getVERSION_PATH(); // 路径
        String versioncode = "";
        String fsName = "";
        File f = new File(path);
        if (!f.exists()) {
            LOGGER.info(path + " not exists");
            return AjaxResponse.reponseBody(Constant.FAIL_CODE, Constant.FAIL_MSG, null);
        }
        File fa[] = f.listFiles();
        for (int i = 0; i < fa.length; i++) {
            File fs = fa[i];
            if (fs.isFile()) {
                if (fs.getName().toLowerCase().endsWith("apk")) {
                    fsName = fs.getName();
                    String code = fsName.substring(fsName.indexOf("c") + 1, fsName.indexOf("c") + 2);
                    versioncode = code;
                    LOGGER.info(fsName);
                }

            }
        }
        JSONObject result = new JSONObject();
        result.put("versionCode", versioncode);
        result.put("versionName", fsName);
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, result);
    }
    

    @ApiOperation(value = "apk下载", notes = "请求参数:<br>" + "")
    @ResponseBody
    @RequestMapping(value = "/downApk", method = RequestMethod.GET)
    public void downApk(HttpServletRequest request, HttpServletResponse response,
            @RequestParam("versionName") String versionName) {

        String path = localConfig.getVERSION_PATH();
        String fullPath = path + versionName;

        File downloadFile = new File(fullPath);
        System.out.println("file=============" + new File(".").getAbsolutePath());

        ServletContext context = request.getServletContext();
        String mimeType = context.getMimeType(fullPath);
        if (mimeType == null) {
            // set to binary type if MIME mapping not found
            mimeType = "application/octet-stream";
            System.out.println("context getMimeType is null");
        }
        System.out.println("MIME type: " + mimeType);
        response.setContentType(mimeType);
        response.setContentLength((int) downloadFile.length());
        String headerKey = "Content-Disposition";
        String headerValue = String.format("attachment; filename=\"%s\"", versionName);
        response.setHeader(headerKey, headerValue);
        try {
            InputStream myStream = new FileInputStream(fullPath);
            IOUtils.copy(myStream, response.getOutputStream());
            response.flushBuffer();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    
    
    
    @ApiOperation(value = "自动DN 根据清单号查询", notes = "请求参数:<br>")
    @ResponseBody
    @RequestMapping(value = "/getPACKING_LIST", method = RequestMethod.POST)
    public AjaxResponse getPACKING_LIST(@RequestParam("pPackingID") String pPackingID) {

        LOGGER.info("-------pPackingID=[" + pPackingID + "]");

        List<Hu_Info> list = Mod_FG.ZBAPI_PACKING_LIST_STATUS(pPackingID);
        JSONObject result = new JSONObject();
        result.put("record", list);
        result.put("information", Mod_FG.result);
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, result);
    }
    
    @ApiOperation(value = "自动DN 查询包装清单号下的HU号", notes = "请求参数:<br>pPackingID 包装清单号，如有多个清单号请逗号间隔<br> pUserType 用户类型")
    @ResponseBody
    @RequestMapping(value = "/getPACKING_LIST_AND_HU", method = RequestMethod.POST)
    public AjaxResponse getPACKING_LIST_AND_HU(@RequestParam("pPackingID") String pPackingID,@RequestParam("pUserType") String pUserType) {

        LOGGER.info("-------pPackingID=[" + pPackingID + "] pUserType=["+pUserType+"]");
        List<String> packinglist = new ArrayList<String>();
        String[] packingIds = pPackingID.split(",");
        for(String packingid : packingIds) {
            packinglist.add(packingid);
        }
        List<Hu_Info> list = Mod_FG.ZBAPI_PACKING_LIST_AND_HU(packinglist,pUserType);
        JSONObject result = new JSONObject();
        result.put("record", list);
        result.put("information", Mod_FG.result);
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, result);
    }
    
    @ApiOperation(value = "创建DN", notes = "请求参数:<br>pPackingID 包装清单号，如有多个清单号请逗号间隔<br> pUserType 用户类型<br> barcodeUser 用户名称")
    @ResponseBody
    @RequestMapping(value = "/createDN", method = RequestMethod.POST)
    public AjaxResponse createDN(@RequestParam("pPackingID") String pPackingID,@RequestParam("pUserType") String pUserType,@RequestParam("barcodeUser") String barcodeUser) {
        LOGGER.info("-------pPackingID=[" + pPackingID + "] pUserType=["+pUserType+"] barcodeUser["+barcodeUser+"]");
        List<String> packinglist = new ArrayList<String>();
        String[] packingIds = pPackingID.split(",");
        for(String packingid : packingIds) {
            packinglist.add(packingid);
        }
        List<Hu_Info> list = Mod_FG.ZBAPI_PL_CREATE_DN_AND_PGI(packinglist,pUserType,barcodeUser,null,null,null);
        JSONObject result = new JSONObject();
        result.put("record", list);
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, result);
    }
    
    @ApiOperation(value = "打印DN", notes = "请求参数:<br>deliveryNo DN号，如有多个清单号请逗号间隔<br> barcodeUser 用户名称")
    @ResponseBody
    @RequestMapping(value = "/email_dn_barcode", method = RequestMethod.POST)
    public AjaxResponse email_dn_barcode(@RequestParam("deliveryNo") String deliveryNo,@RequestParam("barcodeUser") String barcodeUser) {
        LOGGER.info("-------deliveryNo=[" + deliveryNo + "] barcodeUser["+barcodeUser+"]");
        List<String> dnlist = new ArrayList<String>();
        String[] packingIds = deliveryNo.split(",");
        for(String packingid : packingIds) {
            dnlist.add(packingid);
        }
        Return_Result result = Mod_FG.ZBAPI_EMAIL_DN_BARCODE(dnlist,barcodeUser);
        
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, result);
    }
    
    
    @ApiOperation(value = "内厂棉杯收货", notes = "pHuNo  Hu 号，如有多个请逗号间隔")
    @ResponseBody
    @RequestMapping(value = "/save_Hu_GOODS_MOV_2A", method = RequestMethod.POST)
    public AjaxResponse save_Hu_GOODS_MOV_2A(@RequestParam("pHuNo") String pHuNo,
            @RequestParam("pLocation") String pLocation, @RequestParam("user_type") String user_type) {
        LOGGER.info("pHuNo=" + pHuNo + "   pLocation=" + pLocation + "    user_type=" + user_type);
        String huNo[] = pHuNo.split(",");
        List<String> list = new ArrayList<String>();
        for (String str : huNo) {
            list.add(str);
        }
        List<Hu_Info> listhuinfo = Mod_FG.ZBAPI_GET_DATA_BY_HU(list, user_type);
        Return_Result res = Sap_Operation.Save_fgwh_Goods_Mov(list, listhuinfo, pLocation, user_type);
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, res);
    }
    
    @ApiOperation(value = "内厂棉杯转厂", notes = "pHuNo  Hu 号，如有多个请逗号间隔")
    @ResponseBody
    @RequestMapping(value = "/move_to_plant_storage_hu", method = RequestMethod.POST)
    public AjaxResponse move_to_plant_storage_hu(@RequestParam("pHuNo") String pHuNo,
            @RequestParam("factory") String factory,@RequestParam("whKo") String whKo,
            @RequestParam("user_type") String user_type) {
        LOGGER.info("pHuNo=" + pHuNo + "   factory=" + factory + "      whKo="+whKo+"    user_type=" + user_type);
        String huNo[] = pHuNo.split(",");
        List<String> list = new ArrayList<String>();
        for (String str : huNo) {
            list.add(str);
        }
        Return_Result res = Mod_FG.ZBAPI_MOVE_TO_PLANT_STORAGE_HU(list, factory, whKo, user_type);
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, res);
    }
    
    
    @ApiOperation(value = "根据盘点单号和仓位查询", notes = "请求参数:<br>")
    @ResponseBody
    @RequestMapping(value = "/getStockTakeItem", method = RequestMethod.POST)
    public AjaxResponse getStockTakeItem(@RequestParam("pBarcode") String pBarcode,@RequestParam("pLocationID") String pLocationID) {

        LOGGER.info("-------pBarcode=[" + pBarcode + "]    pLocationID=["+pLocationID+"]");

        List<St_Item> list = Mod_FG.GetStockTakeItem(pBarcode,pLocationID);
        JSONObject result = new JSONObject();
        result.put("record", list);
        result.put("information", Mod_FG.result);
        return AjaxResponse.reponseBody(Constant.SUCCESS_CODE, Constant.SUCCESS_MSG, result);
    }
}
